<? 
	$title="Delete photo album"; 
	$pageid="5";
	$accessid="a00";
	
	require("required/dbconnect.php");	
	require("required/header.php");
	require("required/function.php");
	
	
	if(isset($_POST['btnsubmit']))
	{
		$id=$_POST['id'];
		$get_photo=mysql_query("select * from os_photogallery where album_id=$id")or die(mysql_error());
		
		while($a=mysql_fetch_array($get_photo,MYSQL_ASSOC))
		{
			$photo_name=$a['name'];
			$file_l = "../photo_gallery/$photo_name";
			$file_s = "../photo_gallery/thumbnails/$photo_name";
			unlink($file_l);
			unlink($file_s);
		}
		$delete_photo=mysql_query("delete from os_photogallery where album_id=$id");
		$delete_album=mysql_query("delete from os_photoalbum where id=$id");
		header("Location:photo_album.php?action=2");
	}
	else
	{
	
		$enid=$_GET['id'];
	
	
?>
<table width="100%"  cellpadding="0" cellspacing="5" height="300">
				
	<td width="16%" valign="top">
		<? require("required/menu.php") ?>
	</td>
	<td width="84%" align="left" valign="top">
	<table width="95%" cellpadding="2" cellspacing="1">
	<tr>
		<td height="20" colspan="7" align="left" class="title">Delete record</td>
	</tr>
	<tr>
		<td>Confirm to delete photo album? all the photo under this album will be deleted as well</td>
	</tr>
	<tr>
		<td colspan="3" align="center">
		<form action="<?= $_SERVER['PHP_SELF'] ?>" method="post">
		<input type="hidden" value="<?= $enid ?>" name="id">
		<input type="submit" value="Yes" name='btnsubmit' class="button">
		<input type="button" value="No" onClick="history.go(-1)" class="button">
		</form>
		</td>
	</tr>
	</table>
	</td> 
</table>
<? } require("required/footer.php"); ?>
